<template>
  <view class="index">
    <view class="jtop">
      <view class="status_bar"><!-- 这里是状态栏 --></view>
      <view class="jtop_l" @tap="navigateBack"
        ><image src="../../static/img/ic_back_white.png"></image
      ></view>
      <!-- <view class="jtop_l" @tap="navigateBack">关闭</view> -->
      <view class="jtop_c">
        <view> {{ nian }}年 </view>
      </view>
      <view class="jtop_r" @tap="jshow_pop"
        ><image src="../../static/img/ic_ellipsis_white.png"></image
      ></view>
    </view>

    <view class="tophr"></view>

    <view class="cm_t">
      <view class="cm_tb">
        <view
          class="cm_tt"
          :class="true == item.actived ? 'active' : ''"
          @click="labelBtn(index)"
          v-for="(item, index) in items"
          :key="item.id"
        >
          {{ item.name }}
        </view>
      </view>
    </view>

    <!-- 无内容 -->
    <view class="no" v-if="!nodata">
      <view class="no_t">
        <image src="../../static/img/index/2/ic_no data_grey.png"></image>
      </view>
      <view class="no_c">
        暂无数据
      </view>
    </view>

    <view v-if="nodata">
      <view class="cmt">
        上下班统计·次
      </view>
      <view class="cmb">
        <view class="cmbb">
          <view class="cmbbl"> </view>
          <view class="cmbbr">
            正常20天
          </view>
        </view>
        <view class="cmbb">
          <view class="cmbbl2"> </view>
          <view class="cmbbr">
            异常8天
          </view>
        </view>
      </view>

      <view class="clf">
        <view class="clfb">
          <view class="clfb_t">
            1
          </view>
          <view class="clfb_f">
            迟到
          </view>
        </view>
        <view class="clfb">
          <view class="clfb_t">
            10
          </view>
          <view class="clfb_f">
            早退
          </view>
        </view>
        <view class="clfb">
          <view class="clfb_t">
            0
          </view>
          <view class="clfb_f">
            旷工
          </view>
        </view>
        <view class="clfb">
          <view class="clfb_t">
            0
          </view>
          <view class="clfb_f">
            缺卡
          </view>
        </view>
        <view class="clfb">
          <view class="clfb_t">
            0
          </view>
          <view class="clfb_f">
            地点异常
          </view>
        </view>
        <view class="clfb">
          <view class="clfb_t">
            0
          </view>
          <view class="clfb_f">
            设备异常
          </view>
        </view>
      </view>
    </view>

    <!-- 弹出层 -->
    <view :class="[ashowpop ? 'tc' : 'tc hide']">
      <view class="jtop_bj" @click="jshow_pop"></view>

      <view class="tc_fbox">
        <view class="tc_fbox_bt2" @click="jshow_pop">
          生成本月考勤报表
        </view>
        <view class="tc_fbox_bt" @click="jshow_pop">
          取消
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import request from '@/common/request.js';
import RenCalendar from '@/components/ren-calendar/ren-calendar.vue';
export default {
  components: {
    RenCalendar,
  },

  data() {
    return {
      repeat_click: true,
      curDate: '',
      markDays: ['2020-08-01', '2020-08-02', '2020-08-03'],
      collapsible: false,
      ashowpop: false,

      nian: '',
      yue: '',

      nodata: false,
      jqeditid: '',
      ashowpop2: false,
      projectId: uni.getStorageSync('dqfull_name').id,
      today: '',
      week: '',
      jimg: '',
      zong: '0',

      items: [
        {
          name: '1月',
          id: '1',
          actived: true,
        },
        {
          name: '2月',
          id: '2',
          actived: false,
        },
        {
          name: '3月',
          id: '3',
          actived: false,
        },
        {
          name: '4月',
          id: '4',
          actived: false,
        },
        {
          name: '5月',
          id: '5',
          actived: false,
        },
        {
          name: '6月',
          id: '6',
          actived: false,
        },
        {
          name: '7月',
          id: '7',
          actived: false,
        },
        {
          name: '8月',
          id: '8',
          actived: false,
        },
        {
          name: '9月',
          id: '9',
          actived: false,
        },
        {
          name: '10月',
          id: '10',
          actived: false,
        },
        {
          name: '11月',
          id: '11',
          actived: false,
        },
        {
          name: '12月',
          id: '12',
          actived: false,
        },
      ],
    };
  },

  onShow() {
    // let today = this.$refs.ren.getToday().date;
    this.nian = new Date().getFullYear();
    this.yue = new Date().getMonth() + 1;

    var date = new Date();
    var Y = date.getFullYear();
    var M =
      date.getMonth() + 1 < 10
        ? '0' + (date.getMonth() + 1)
        : date.getMonth() + 1;
    var D = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();

    var now = new Date();
    var day = now.getDay();
    var weeks = new Array(
      '星期日',
      '星期一',
      '星期二',
      '星期三',
      '星期四',
      '星期五',
      '星期六',
    );
    var week = weeks[day];

    this.week = week;

    let today = Y + '-' + M + '-' + D;
    this.jt = Y + '年' + M + '月' + D + '日';
    this.today = today;
    console.log('ddddd:', today);
    this.curDate = today;

    // this.markDays.push(today);

    this.labelBtn(uni.getStorageSync('yue') - 1);

    // this.lb(this.curDate);
  },

  onReady() {
    // let today = this.$refs.ren.getToday().date;
    // this.curDate = today;
    // this.markDays.push(today);
  },
  methods: {
    labelBtn(index) {
      console.log(index);
      for (let i in this.items) {
        this.items[i].actived = false;
      }

      this.items[index].actived = true;

      var jtitle = this.items[index];

      console.log(index);

      uni.setStorageSync('dqfull_name', this.items[index]);

      this.dqfull_name = this.items[index];
      console.log(
        'jqeditzzz:',
        uni.getStorageSync('nian') + '-' + this.items[index]['id'],
      );
      this.lb(uni.getStorageSync('nian') + '-' + this.items[index]['name']);
    },

    lb(e) {
      console.log('lbbb:', e);
      var cc = e.slice(0, 7);

      // 获取列表信息
      request({
        url: `/modor/v1/project/${this.projectId}/work/type/2/payment/statistics`,
        method: 'GET',
        data: {
          time: e,
        },

        success: res => {
          console.log('项目列表', res);
          console.log(res.data.data.length);
          if (res.data.success == true) {
            console.log('1111:', res.data.data.length);
            if (res.data.data.length > 0) {
              // this.items = res.data.data;
              // console.log(this.items);
              // var cc = 0;
              // for(var i=0;i< res.data.data.length;i++){
              // 	cc = cc + res.data.data[i]["payedAmount"];
              // }
              // this.zong = cc;
              this.nodata = true;
            } else {
              // this.items = "";
              this.nodata = false;
            }
          } else {
            this.repeat_click = true;
            uni.showToast({
              title: res.data.msg,
              icon: 'none',
            });
          }
        },
        fail: () => {
          this.repeat_click = true;
          uni.showToast({
            title: '服务器开小差，请稍后~',
            icon: 'none',
          });
          return false;
        },
      });
    },

    jshow_pop() {
      this.ashowpop = !this.ashowpop;
    },

    navigateBack() {
      uni.navigateBack();
    },
    onDayClick(data) {
      this.curDate = data.date;
    },
  },
};
</script>

<style>
.cmt {
  width: 690rpx;
  height: auto;
  display: block;
  float: left;
  margin: 30rpx 30rpx 40rpx;
  color: #999999;
  font-size: 28rpx;
  line-height: 36rpx;
}
.cmb {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  border-bottom: 1px solid #dddddd;
}
.cmbb {
  width: auto;
  height: auto;
  display: block;
  float: left;
  margin: 0rpx 40rpx 40rpx 120rpx;
}
.cmbbl {
  width: 20rpx;
  height: 20rpx;
  border-radius: 20rpx;
  background: #256aff;
  margin: 10rpx 10rpx 0 0;
  display: block;
  float: left;
}
.cmbbl2 {
  width: 20rpx;
  height: 20rpx;
  border-radius: 20rpx;
  background: #ffaa20;
  margin: 10rpx 10rpx 0 0;
  display: block;
  float: left;
}
.cmbbr {
  width: auto;
  height: auto;
  display: block;
  float: left;
  margin: 0rpx 0rpx 0rpx;
  color: #000000;
  font-size: 34rpx;
  line-height: 42rpx;
}

.clf {
  width: 90%;
  height: auto;
  display: block;
  float: left;
  margin: 0rpx 5%;
}
.clfb {
  width: 33%;
  height: auto;
  display: block;
  float: left;
}
.clfb_t {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  text-align: center;
  margin: 50rpx 0rpx 0;
  color: #000000;
  font-size: 36rpx;
  line-height: 44rpx;
}
.clfb_f {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  text-align: center;
  margin: 10rpx 0rpx 0;
  color: #999999;
  font-size: 28rpx;
  line-height: 36rpx;
}

.tc {
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
  display: block;
}
.jtop_bj {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10000;
}
.tc_fbox_bt {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-top: 20rpx solid #f2f2f2;
  background: #ffffff;
}
.tc_fbox {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  background: #f2f2f2;
  position: fixed;
  left: 0;
  bottom: 0;
  z-index: 10001;
}
.tc_fbox_bt2 {
  width: 100%;
  height: 90rpx;
  line-height: 90rpx;
  display: block;
  float: left;
  text-align: center;
  font-size: 36rpx;
  color: #000000;
  border-top: 0rpx solid #f2f2f2;
  background: #ffffff;
}

.cm_t {
  width: 100%;
  height: 160rpx;
  background: #256aff;
  display: block;
  float: left;
  overflow: overlay;
}
.cm_tb {
  width: 1250rpx;
  height: auto;
  display: block;
  float: left;
  margin: 35rpx 40rpx;
}
.cm_tt {
  width: 80rpx;
  height: auto;
  border-radius: 80rpx;
  line-height: 80rpx;
  text-align: center;
  font-size: 32rpx;
  color: #ffffff;
  display: block;
  float: left;
  margin: 0 10rpx;
}
.cm_tt.active {
  background: #ffffff;
  color: #256aff;
}

.cf {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  border-bottom: 1px solid #dddddd;
}
.cf_b {
  width: 690rpx;
  height: auto;
  display: block;
  float: left;
  margin: 0 30rpx;
}
.cf01 {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  color: #000000;
  font-size: 28rpx;
  line-height: 36rpx;
  margin: 20rpx 0;
}
.cf02 {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  color: #999999;
  font-size: 24rpx;
  line-height: 32rpx;
  margin: 0 0 20rpx;
}
.cf03 {
  width: 100rpx;
  height: auto;
  display: block;
  float: left;
  color: #000000;
  font-size: 34rpx;
  line-height: 32rpx;
  margin: 40rpx 40rpx 40rpx 0;
}
.cf04 {
  width: 500rpx;
  height: auto;
  display: block;
  float: left;
  margin: 0 0rpx;
}
.cf04t {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  color: #000000;
  font-size: 28rpx;
  line-height: 36rpx;
  margin: 20rpx 0 10rpx;
}
.cf04f {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  color: #999999;
  font-size: 24rpx;
  line-height: 32rpx;
  margin: 0rpx 0 22rpx;
}

.no {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  margin: 400rpx 0 0;
}
.no_t {
  width: 200rpx;
  height: 200rpx;
  display: block;
  float: left;
  margin: 0 275rpx;
  background: #ffffff;
  border-radius: 200rpx;
}
.no_t image {
  width: 140rpx;
  height: 140rpx;
  display: block;
  float: left;
  margin: 30rpx;
}
.no_c {
  width: 100%;
  height: auto;
  display: block;
  float: left;
  margin: 30rpx 0 50rpx;
  color: #666666;
  font-size: 32rpx;
  line-height: 40rpx;
  text-align: center;
}
.no_f {
  width: 460rpx;
  height: 94rpx;
  line-height: 94rpx;
  background: #256aff;
  border-radius: 10rpx;
  display: block;
  float: left;
  margin: 0 145rpx;
  color: #ffffff;
  font-size: 36rpx;
  text-align: center;
}
.no_f:active {
  background: linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.199437),
      rgba(0, 0, 0, 0.199437)
    ),
    #256aff;
}

.tophr {
  width: 100%;
  height: 88rpx;
}
.uni-searchbar {
  box-shadow: none;
}
.index {
  background: #ffffff;
  width: 100%;
  height: auto;
}
.jtop {
  width: 100%;
  height: 88rpx;
  background: #256aff;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
}
.jtop_l {
  width: auto;
  height: 88rpx;
  display: block;
  float: left;
  font-size: 32rpx;
  color: #000000;
  line-height: 88rpx;
  margin: 0 0 0 30rpx;
}
.jtop_l image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
  margin: 20rpx 0 20rpx 0;
}
.jtop_lt {
  margin: 0 0 0 10rpx;
}
.jtop_r {
  width: 48rpx;
  color: #ffffff;
  text-align: right;
  height: 48rpx;
  display: block;
  float: right;
  margin: 20rpx 20rpx 0 0;
}
.jtop_rl {
  margin: 20rpx 30rpx 0 0;
}
.jtop_r image {
  width: 48rpx;
  height: 48rpx;
  display: block;
  float: left;
}
.jtop_c {
  width: 70%;
  height: 48rpx;
  line-height: 48rpx;
  display: block;
  float: left;
  position: fixed;
  top: 20rpx;
  left: 15%;
  text-align: center;
  font-size: 36rpx;
  color: #ffffff;
}
.jtop_c image {
  width: 36rpx;
  height: 36rpx;
  display: inline-block;
  float: none;
  margin-bottom: -5rpx;
  margin-left: 5rpx;
}
.jtop_b {
  width: 100%;
  height: auto;
  background: #ffffff;
  position: fixed;
  top: 88rpx;
  left: 0;
  z-index: 1001;
}
.jtop_c1 {
  display: inline-block;
  margin: 0 20rpx;
  color: #ffffff;
}
.jtop_c1.active {
  color: #ffffff;
}
</style>
